<template>
  <div>
    <div class="login-container">
      <form>
        <div class="form-group">
          <label for="exampleInputEmail1">用户名</label>
          <input v-model.trim="userName" type="text" class="form-control" id="exampleInputEmail1" placeholder="用户名">
        </div>
        <div class="form-group">
          <label for="exampleInputPassword1">密码</label>
          <input v-model.trim="password" type="password" class="form-control" id="exampleInputPassword1" placeholder="密码">
        </div>
        <button @click="loginClick" type="button" class="btn btn-default">登录</button>
      </form>
    </div>
  </div>
</template>


<script>
export default {
    data(){
      return {
        userName: '',
        password: ''
      }
    },
    methods: {
      loginClick(){
        if(this.userName && this.password){
          localStorage.setItem('user','user');
          if(this.$route.query.redirect){
            this.$router.push(this.$route.query.redirect)
          }else{
            this.$router.push('/home')
          }
          
        }else{
          alert('请输入用户名...')
        }
      }
    }
}
</script>


<style scoped>
.login-container {
  width: 600px;
  height: 260px;
  margin: 80px auto;
  background: #fff;
  border-radius: 5px;
  background-color: #e8e2e2;
  padding: 20px;
}
</style>
